package com.system.jfm.Components;

import com.system.jfm.Components.PlaceHolder;

import javax.swing.*;

public class LabelPasswordTextField extends JPanel {
    public JLabel label;
    JPasswordField txt_box;

    public LabelPasswordTextField(String label_txt, int width, int height, double per){
        label = new JLabel(label_txt);
        txt_box = new JPasswordField();

        this.setLayout(null);
        this.setSize(width,height);

        label.setBounds(0,0,(int) (width*per),height);
        txt_box.setBounds(label.getWidth(),0,this.getWidth()-label.getWidth(),height);



        this.add(label);
        this.add(txt_box);
    }
    public LabelPasswordTextField(String label_txt, int label_width, int label_height, int txt_width, int txt_height){
        label = new JLabel(label_txt);
        txt_box = new JPasswordField();

        this.setSize(label_width+txt_width,label_height+txt_height);

        label.setBounds(0,0,label_width,label_height);
        txt_box.setBounds(label_width,0,txt_width,txt_height);

        this.setLayout(null);

        this.add(label);
        this.add(txt_box);
    }
    public String getText(){
        return txt_box.getText();
    }
    public void setPlaceHolder(String hitTxt) {
        txt_box.addFocusListener(new PlaceHolder(txt_box,hitTxt));
    }
}
